def twosum(alist,targetnum):
    for i,j in enumerate(alist):
        k = i+1
        if alist[k:].count(targetnum - j) > 0:
            for n in range(alist[k:].count(targetnum - j)):
                b = alist.index(targetnum - j,k)
                print(i,b)
                k=b+1
a = [1,2,4,3,5,0,5,-8,7,0,3,5,7]
twosum(a,6)